<template>
    <div class="app-container">
        <div class="head">
            <img src="@/assets/img/Layout/position.png" />
            <p class="see-block">收款单列表</p>
        </div>
        <div class="view-container">
            <el-form :model="queryParams" ref="queryForm" :inline="true">
                <el-form-item label="客户" prop="customerName">
                <el-input
                    v-model="queryParams.customerName"
                    placeholder="按名称模糊查询"
                    clearable
                    size="small"
                    style="width: 230px;"
                    @keyup.enter.native="handleQuery"
                />
                </el-form-item>
                <el-form-item label="单据编码" prop="collectionCode">
                <el-input
                    v-model="queryParams.collectionCode"
                    placeholder="按编码查询"
                    clearable
                    size="small"
                    @keyup.enter.native="handleQuery"
                />
                </el-form-item>
                <el-form-item label="状态" prop="status" >
                    <el-select
                        v-model="queryParams.status"
                        placeholder="全部"
                        clearable
                        size="small"
                        style="width:100px;"
                    >
                        <el-option label="待收款" value="1">待收款</el-option>
                        <el-option label="已收款" value="2">已收款</el-option>
                        <el-option label="部分核销" value="3">部分核销</el-option>
                        <el-option label="已核销" value="4">已核销</el-option>
                    </el-select>
                </el-form-item>
                <el-form-item label="类型" prop="collectionType" >
                    <el-select
                        v-model="queryParams.collectionType"
                        placeholder="全部"
                        clearable
                        size="small"
                        style="width:100px;"
                    >
                        <el-option label="销售货款" value="1">销售货款</el-option>
                        <el-option label="销售退货" value="2">销售退货</el-option>
                        <el-option label="预收款" value="3">预收款</el-option>
                    </el-select>
                </el-form-item>
                <el-form-item>
                    <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery" class="list-search btn-success" color="#5ED4D4">搜索</el-button>
                    <el-button icon="el-icon-refresh" size="mini" @click="resetQuery" class="list-search">重置</el-button>
                </el-form-item>
            </el-form>
            <!-- <el-row :gutter="10" class="mb8">
                <el-col :span="1.5">
                    <el-button
                        class="btn-success"
                        type="primary"
                        icon="el-icon-plus"
                        size="mini"
                        @click="add()"
                        v-hasPermi="['system:billsMakeCollections:insert']"
                    >新建</el-button>
                </el-col>
            </el-row> -->
            <el-table :data="list" @row-click="handleView" border>
                <el-table-column label="序号" type="index" align="center" width="50">
                    <template slot-scope="scope">
                        <span>{{(queryParams.pageNum - 1) * queryParams.pageSize + scope.$index + 1}}</span>
                    </template>
                </el-table-column>
                <el-table-column label="单据编号"  align="center" prop="collectionCode" width="150" />
                <el-table-column label="销售订单编号"  align="center" prop="salesOrderCode" width="150" />
                <el-table-column label="客户" align="center" prop="customerName" />
                <el-table-column label="收款方式" align="center" prop="collectionMethod">
                    <template slot-scope="scope">
                        {{ scope.row.collectionMethod == '1' ? '银行' : scope.row.collectionMethod == '2' ? '现金' : '' }}
                    </template>
                </el-table-column>
                <el-table-column label="类型" align="center" prop="collectionType">
                    <template slot-scope="scope">
                        {{ scope.row.collectionType == '1' ? '销售货款' : scope.row.collectionType == '2' ? '销售退货' : scope.row.collectionType == '3' ? '预收款' : '' }}
                    </template>
                </el-table-column>
                <el-table-column label="应收金额（元）" align="center" prop="pendingPayment" />
                <el-table-column label="已收金额（元）" align="center" prop="money" />
                <el-table-column label="备注" align="center" prop="remark" />
                <el-table-column label="状态" align="center" prop="status">
                    <template slot-scope="scope">
                        <div v-if="scope.row.status == 1" style="color:#13C2C2">待收款</div>
                        <div v-if="scope.row.status == 2" style="color:#52C41A">已收款</div>
                        <div v-if="scope.row.status == 3" style="color:#fd562c">部分核销</div>
                        <div v-if="scope.row.status == 4" style="color:#52C41A">已核销</div>
                        <!-- {{ scope.row.status == '1' ? '待收款' : scope.row.status == '2' ? '已收款' : scope.row.status == '3' ? '部分核销' : scope.row.status == '4' ? '已核销' : '' }} -->
                    </template>
                </el-table-column>
            </el-table>
            <pagination
                v-show="total > 0"
                :total="total"
                :page.sync="queryParams.pageNum"
                :limit.sync="queryParams.pageSize"
                @pagination="getList"
            />
        </div>
    </div>
</template>

<script>
import { billsReceiptList } from "@/api/system/billsReceipt/billsReceipt"
export default {
    name: "list",
    data() {
        return {
            // 总条数
            total: 0,
            // 列表数据
            list: [],
            // 查询参数
            queryParams: {
                pageNum: 1,
                pageSize: 10,
                status: undefined,
                customerName: undefined,
                collectionCode: undefined,
                collectionType: undefined
            }
        }
    },
    created() {
        this.getList()
    },
    methods: {
        // 获取列表
        getList() {
            billsReceiptList(this.addDateRange(this.queryParams)).then(res => {
                this.list = res.rows
                this.total = res.total
            })
        },
        // 搜索按钮
        handleQuery() {
            this.queryParams.pageNum = 1
            this.getList()
        },
        // 重置按钮
        resetQuery() {
            this.resetForm("queryForm")
            this.handleQuery()
        },
        // 新建
        add(){
            this.$router.push({path:"/receiptAndPayment/billsReceipt/add"})
        },
        // 查看
        handleView(row) {
            this.$router.push({path:"/receiptAndPayment/billsReceipt/detail", query:{ id: row.collectionId }})
        }
    }
}
</script>